package cn.ym.system.controller;

import cn.ym.basic.exception.BusinessException;
import cn.ym.basic.utils.AjaxResult;
import cn.ym.basic.utils.PageList;
import cn.ym.system.domain.Systemdictionarydetail;
import cn.ym.system.domain.Systemdictionarytype;
import cn.ym.system.query.SystemdictionarytypeQuery;
import cn.ym.system.service.SystemdictionarytypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 接口类：数据字典类型
 */
@RestController
@RequestMapping("/systemdictionarytype")
@Api(value = "数据字典类型接口" ,description = "处理数据字典类型的所有请求")
public class SystemdictionarytypeController {
    @Autowired
    private SystemdictionarytypeService systemdictionarytypeService;
    /**
     * 接口：添加或修改数据字典类型信息
     */
    @ApiOperation(value = "添加或修改数据字典类型信息")
    @PutMapping
    public AjaxResult save(@RequestBody Systemdictionarytype systemdictionarytype){

            if(systemdictionarytype.getId()==null){
                systemdictionarytypeService.add(systemdictionarytype);
            }else {
                systemdictionarytypeService.update(systemdictionarytype);
            }
            return new AjaxResult();


    }

    /**
     *接口：删除单个数据字典类型信息
     */
    @ApiOperation(value = "删除单个数据字典类型信息")
    @DeleteMapping("/{id}")
    public AjaxResult del(@PathVariable("id") Long id){

            systemdictionarytypeService.delete(id);
            return new AjaxResult();

    }

    /**
     * 接口：查询所有数据字典类型信息
     */
    @ApiOperation(value = "查询所有数据字典类型信息")
    @GetMapping
    public List<Systemdictionarytype> findAll(){
        return systemdictionarytypeService.findAll();
    }

    /**
     * 接口：查询单个数据字典类型信息
     */
    @ApiOperation(value = "查询单个数据字典类型信息")
    @GetMapping("/{id}")
    public Systemdictionarytype findOne(@PathVariable("id") Long id){
        return systemdictionarytypeService.findOne(id);
    }


    /**
     * 接口：批量删除数据字典类型信息
     */
    @ApiOperation(value = "批量删除数据字典类型信息")
    @PatchMapping
    public AjaxResult patchDel(@RequestBody Long[]  ids){

            systemdictionarytypeService.patchDel(ids);
            return new AjaxResult();

    }

    /**
     * 接口：分页查询 + 高级查询
     */
    @ApiOperation(value = "分页查询或高级查询")
    @PostMapping
    public PageList<Systemdictionarytype> queryPage(@RequestBody SystemdictionarytypeQuery systemdictionarytypeQuery){
        return systemdictionarytypeService.queryPage(systemdictionarytypeQuery);
   }


}
